import {
  createRouter,
  createWebHashHistory,
  createWebHistory,
} from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(),

  routes: [
    {
      path: '/',
      redirect: '/dashboard',
    },
    {
      path: '/dashboard',
      name: '首页',
      component: () =>
        import(/* webpackChunkName: "about" */ '../views/dashboard/index'),
    },
    {
      path: '/dictionary',
      name: '词典',
      component: () =>
        import(/* webpackChunkName: "about" */ '../views/dictionary/index'),
    },
    {
      path: '/dictionary-word',
      name: '单词练习',
      component: () =>
        import(/* webpackChunkName: "about" */ '../views/dictionary/word'),
    },
    {
      path: '/video',
      name: '选择剧集',
      component: () =>
        import(/* webpackChunkName: "about" */ '../views/video/index'),
    },
    {
      path: '/video-dictating',
      name: '听写练习',
      component: () =>
        import(/* webpackChunkName: "about" */ '../views/video/dictating'),
    },
    {
      path: '/login',
      name: '登录',
      component: () => import(/* webpackChunkName: "login" */ '../views/login'),
    },
    {
      path: '/404',
      name: '页面不存在',
      component: () =>
        import(/* webpackChunkName: "notFound" */ '../views/404'),
    },
  ],
})

export const secondaryRoutes = {
  home: '/dashboard',
  dictionary: '/dictionary',
  dictionaryWord: '/dictionary-word',
  video: '/video',
  dictating: '/video-dictating',
}

export const resetRoute = function () {
  let routes = router.getRoutes()
  routes.forEach((route) => {
    if (route.path !== '/login' && route.path !== '/404') {
      router.removeRoute(route.name)
    }
  })
}
export default router
